package com.kaibes.module.email.sender;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.kaibes.module.value.KeyValueService;

@Service
public class MailSenderService {

    @Autowired
    private SenderInfo senderInfo;
    @Autowired
    private KeyValueService keyValueService;
    
    public boolean save(SenderInfo temp) {
        boolean flag = keyValueService.saveObject(temp);
        if (flag) {
            senderInfo.setHost(temp.getHost());
            senderInfo.setPort(temp.getPort());
            senderInfo.setUsername(temp.getUsername());
            senderInfo.setPassword(temp.getPassword());
        }
        return flag;
    }
    
    public SenderInfo get() {
        return keyValueService.getObject(SenderInfo.class);
    }
}
